#pragma once

#include "footage.h"
#include <windows.h>

#ifndef ICACHE_DLL
#define ICACHE_DLL __declspec(dllimport)
#	ifdef _DEBUG
#		pragma comment(lib, "icachedlld.lib")
#	else
#		pragma comment(lib, "icachedll.lib")
#	endif
#endif

namespace icache {

class cache;

class dll {
public:
	ICACHE_DLL dll();
	ICACHE_DLL ~dll();
public:
	///show modal configure dialog
	ICACHE_DLL void configure(HWND hParent = 0);
	//modalees configure dialog manipulation
	ICACHE_DLL void modaless_configure_show(HWND hParent = 0);
	ICACHE_DLL void modaless_configure_hide();
public:
	ICACHE_DLL footage_sptr create_avi_footage(const string & filename);
	ICACHE_DLL footage_sptr create_seq_footage(const string & filename);
	ICACHE_DLL footage_sptr create_still_footage(const string & filename);
	/// selects footage's type depending on filename extension
	ICACHE_DLL footage_sptr create_footage(const string & filename); 
	/// loads footage's data from xml stream
	ICACHE_DLL footage_sptr create_footage(xml::stream & s, string const & reference_path); 
	/// opens file-selection dialog for the user for he to choose a file
	/// if load_as_still_image is on, then places additional check box in dialog allowing the user to load single frame from an image sequence
	ICACHE_DLL footage_sptr create_footage_dialog(bool load_as_still_image = false, HWND hParent = 0);
	ICACHE_DLL cached_image_sptr get_still_image(const string & filename);
	ICACHE_DLL cache & coordinator();
private: //prohibit
	dll(dll const &) { }
	void operator = (dll const &) { }
private:
	struct data;
	data * _data;
};

struct footage_ptr_capsule {
	dll & cache;
	footage_sptr & ptr;
	string const & path;
	footage_ptr_capsule(dll & c, footage_sptr & p, string const & rp) 
		: cache(c), ptr(p), path(rp) { }
};

ICACHE_DLL xml::stream & operator || (xml::stream & s, footage_ptr_capsule & c);

} //namespace icache
